package com.hrsystem.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.hrsystem.entity.JobName;
import com.hrsystem.entity.OrgSecond;
import com.hrsystem.lang.Result;
import com.hrsystem.mapper.JobNameMapper;
import com.hrsystem.service.JobNameService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;


@RestController
public class JobNameController {

    @Resource
    JobNameMapper jobNameMapper;

    @Autowired
    JobNameService jobNameService;

    @Transactional
    @GetMapping("/selectJobName/{id}")
    public Result selectjobNameList(@PathVariable(name = "id") Long id){
        QueryWrapper<JobName> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("cJob_id",id);
        List<JobName> jobNameList = jobNameMapper.selectList(queryWrapper);
        return Result.success(jobNameList);
    }

    @Transactional
    @PostMapping("/AddJobName")
    public Result addJobName(@RequestBody JobName jobName) {
        jobNameService.saveOrUpdate(jobName);
        return Result.success(null);
    }
}
